/**
 * AppDevice.java 
 * Copyright © 2015-3015, 杭州泊享网络科技有限公司
 * 
 * @author Liu Tao
 * @create 2013年8月22日
 */
package com.pshare.appdevice.bean;

import java.time.LocalDateTime;

import com.pshare.enums.OsType;
import com.pshare.util.DateUtils;

/**
 * 登录设备信息
 */
public class AppDevice {

	private Long id;
	private Long userId;
	private Integer osType; // 软件客户端类型1:iOS, 2:Android, 3:Web
	private Integer bizClientType; // 业务逻辑客户端类型，如用户端、商户端等
	private String deviceToken; // 对于iOS而言，就记录deviceToken；对于安卓，就根据实际需要放置数据
	private String model; // 机型
	private LocalDateTime loginTime; // 登录时间
	private Integer unreadCount; // 未读消息条数

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public Integer getOsType() {
		return osType;
	}

	public void setOsType(Integer osType) {
		this.osType = osType;
	}
	
	public String getOsTypeStr() {
		return osType == null ? "" : OsType.getName(osType);
	}

	public Integer getBizClientType() {
		return bizClientType;
	}

	public void setBizClientType(Integer bizClientType) {
		this.bizClientType = bizClientType;
	}

	public String getDeviceToken() {
		return deviceToken;
	}

	public void setDeviceToken(String deviceToken) {
		this.deviceToken = deviceToken;
	}

	public String getModel() {
		return model;
	}

	public void setModel(String model) {
		if (model != null && model.length() > 32) {
			this.model = model.substring(0, 32);
		} else {
			this.model = model;
		}
	}

	public LocalDateTime getLoginTime() {
		return loginTime;
	}

	public void setLoginTime(LocalDateTime loginTime) {
		this.loginTime = loginTime;
	}
	
	public String getLoginTimeStr() {
		return DateUtils.getLocalDateTimeStr(loginTime);
	}

	public Integer getUnreadCount() {
		return unreadCount;
	}

	public void setUnreadCount(Integer unreadCount) {
		this.unreadCount = unreadCount;
	}

}
